package com.wujp.common.template.tools.factory;

import com.wujp.common.template.tools.enums.BeanType;
import com.wujp.common.template.tools.exception.ProcessException;
import com.wujp.common.template.tools.interfaces.BeanFactory;

/**
 * @desc: 普通bean的工厂
 * @author: wujp
 * @create: 2023-01-18 15:20
 */
public class ClassBeanFactory implements BeanFactory {


    @Override
    public <T> T getBean(String beanName) {
        T bean = null;
        try {
            bean = (T) Class.forName(beanName).newInstance();
        } catch (Exception e) {
            throw new ProcessException("ClassBeanFactory初始化bean异常actionName=" + beanName, e);
        }
        return bean;
    }

    @Override
    public String bindingBeanType() {
        return BeanType.ClASS_BEAN.getType();
    }
}
